<template>
	<view :style="themeColor">
		<view class="page">
			<view
				class="flex benben-position-layout flex flex-wrap align-center otherFollow_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }"
			>
				<view class='flex flex-wrap align-center justify-between flex-sub otherFollow_fd0_0'>
					<view
						class='flex flex-wrap align-center justify-center otherFollow_fd0_0_c0'
						@tap.stop="handleJumpDiy"
						data-type="back"
						data-url="1"
					>
						<text class='fu-iconfont2  otherFollow_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view
						class='flex flex-wrap align-stretch justify-center'
						style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
					>
						<text
							class='otherFollow_fd0_0_c1_c0'
							v-if="type=='1' && is_me == 0"
						>TA的关注</text>
						<text
							class='otherFollow_fd0_0_c1_c0'
							v-if="type=='1' && is_me == 1"
						>我的关注</text>
						<text
							class='otherFollow_fd0_0_c1_c0'
							v-if="type=='2' && is_me == 0"
						>TA的粉丝</text>
						<text
							class='otherFollow_fd0_0_c1_c0'
							v-if="type=='2' && is_me == 1"
						>我的粉丝</text>
					</view>
					<view class='flex flex-wrap align-center otherFollow_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<!---flex布局flex布局开始-->
			<view class="flex flex-direction align-stretch benben-flex-layout otherFollow_flex_1">
				<view class='flex align-center justify-center otherFollow_fd1_0'>
					<image
						class='otherFollow_fd1_0_c0'
						mode="aspectFill"
						:src='STATIC_URL+"482.png"'
					></image>
					<input
						class='otherFollow_fd1_0_c1'
						type="text"
						:placeholder="`请输入ID和昵称`"
						confirm-type="search"
						:maxlength="-1"
						placeholder-style="color:#999;font-size:28rpx"
						@confirm="getSearch()"
						v-model="keywords"
					/>
				</view>
				<view
					class="loading_css"
					v-if="isShow"
				>
					<u-loading
						size="36"
						color="#AD3823"
					></u-loading>
					<view>加载中</view>
				</view>
				<block v-else>
					<view
						class='flex align-center otherFollow_fd1_1'
						v-for="(item, index) in list"
						:key='key0'
					>
						<image
							class='otherFollow_fd1_1_c0'
							mode="aspectFill"
							:src='item.head_img'
						></image>
						<view class='flex flex-direction align-stretch flex-sub'>
							<text class='otherFollow_fd1_1_c1_c0'>{{item.user_nickname}}</text>
							<view class='flex flex-wrap align-center otherFollow_fd1_1_c1_c1'>
								<view class='flex flex-wrap align-center'>
									<text>{{item.fans_nums}}</text>
									<text class='otherFollow_fd1_1_c1_c1_c0_c1'>粉丝 </text>
								</view>

								<view class='flex  otherFollow_fd1_1_c1_c1_c1'></view>

								<view class='flex flex-wrap align-center'>
									<text>{{item.community_nums}}</text>
									<text class='otherFollow_fd1_1_c1_c1_c0_c1'>心得</text>
								</view>
							</view>
						</view>
						<block v-if="type == 1">
							<button
								class='otherFollow_fd1_1_c2'
								style="font-family: Alimama DongFangDaKai;"
								@tap.stop="getFollow(item.user_id)"
							>已关注</button>
						</block>
						<block v-if="type == 2">

							<button
								class='otherFollow_fd1_1_c2_2'
								style="font-family: Alimama DongFangDaKai;"
								v-if=" item.is_fans_follow_self == 1 && item.is_self_follow_fans == 1"
								@tap.stop="getFollow(item.fans_id)"
							>互相关注</button>
							<block v-else>
								<button
									class='otherFollow_fd1_1_c2'
									v-if="item.is_fans_follow_self == 1"
									style="font-family: Alimama DongFangDaKai;"
									@tap.stop="getFollow(item.fans_id)"
								>已关注</button>
								<button
									class='otherFollow_fd1_1_c2_1'
									v-if="item.is_self_follow_fans == 1"
									style="font-family: Alimama DongFangDaKai;"
									@tap.stop="getFollow(item.fans_id)"
								>关注</button>
							</block>
						</block>
					</view>
					<view
						class="loadmore"
						v-if="last_page > 1"
					>
						<u-loadmore
							font-size="24"
							:status="status"
							:icon-type="iconType"
							:load-text="loadText"
						/>
					</view>
				</block>
				<view
					class="noData"
					v-if="list.length == 0 && !isShow"
				>
					<image :src='STATIC_URL+"no.png"'></image>
				</view>
			</view>

			<!---flex布局flex布局结束-->


		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {
				"minixPagingListsApi": "",
				"pageingListApiMethod": "",
				"allowOnloadGetList": false,
				"show_id": "1",
				"type": "1", // 1关注 2粉丝 
				"keywords": "",
				"dataList": [],
				"messageInfo": {
					"is_follow": ""
				},
				"user_id": "", // 用户id
				"is_me": 0, // 1是自己  0不是自己

				"isShow": true,
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				user_id,
				type,
				is_me
			} = options
			if (user_id !== undefined) this.user_id = user_id;
			if (type !== undefined) this.type = type;
			if (is_me !== undefined) this.is_me = is_me;
			if (this.type == 1) {
				this.getList();
			} else {
				this.getFensi();
			}
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			if (this.type == 1) {
				this.getList();
			} else {
				this.getFensi();
			}

		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {

				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				if (this.type == 1) {
					this.getList();
				} else {
					this.getFensi();
				}
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			// 关注列表
			getList() {
				this.$api.post(global.API_VERSION + '6552d2bcd3003', {
					user_id: this.user_id,
					keyword: this.keywords,
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 粉丝列表 6552d2cb4a502
			getFensi() {
				this.$api.post(global.API_VERSION + '6552d2cb4a502', {
					user_id: this.user_id,
					keyword: this.keywords,
					page: this.page
				}).then(res => {
					console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			getSearch() {
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				if (this.type == 1) {
					this.getList();
				} else {
					this.getFensi();
				}
			},
			// 关注
			getFollow(user_id) {
				if (this.is_me == 0) return;
				this.$api.post(global.API_VERSION + '6552cbf5eac8e', {
					user_id: user_id
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						this.page = 1;
						this.is_pull = true;
						// this.isShow = true;
						if (this.type == 1) {
							this.getList();
						} else {
							this.getFensi();
						}
					}
				})
			},
		}
	};
</script>
<style
	lang="scss"
	scoped
>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: var(--benbenbgColor1);
		background-size: 100% auto;
	}

	.otherFollow_flex_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/480.png) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.otherFollow_fd0_0_c1_c0 {
		font-size: 40rpx;
		font-weight: 400;
		color: #000000;
		line-height: 88rpx;
	}

	.otherFollow_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: #333;
	}

	.otherFollow_fd0_0_c0 {
		width: 50rpx;
		height: 50rpx;
	}

	.otherFollow_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.otherFollow_flex_1 {
		background: var(--benbenbgColor1);
		padding: 0rpx 24rpx 0rpx 24rpx;
		background-size: 100% auto !important;
	}

	.otherFollow_fd1_1_c2_2 {
		border: 1px solid #62889B;
		background: #F8F8F8;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: rgba(98, 136, 155, 1);
		height: 64rpx;
	}

	.otherFollow_fd1_1_c2_1 {
		border: 1px solid #AD3823;
		background: var(--benbenbgColor2);
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor3);
		height: 64rpx;
	}

	.otherFollow_fd1_1_c2 {
		border: 1px solid #AD3823;
		background: #F8F8F8;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		width: 172rpx;
		line-height: 64rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor4);
		height: 64rpx;
	}

	.otherFollow_fd1_1_c1_c1_c1 {
		background: var(--benbenbgColor6);
		width: 1rpx;
		height: 30rpx;
		margin: 0rpx 10rpx 0rpx 10rpx;
		transform: scaleX(0.5);
	}

	.otherFollow_fd1_1_c1_c1_c0_c1 {
		margin: 0rpx 0rpx 0rpx 10rpx;
	}

	.otherFollow_fd1_1_c1_c1 {
		color: #999999;
		font-size: 24rpx;
		line-height: 33rpx;
		font-weight: 400;
	}

	.otherFollow_fd1_1_c1_c0 {
		color: #000000;
		font-size: 32rpx;
		font-weight: 500;
		line-height: 40rpx;
		margin: 0rpx 0rpx 16rpx 0rpx;
	}

	.otherFollow_fd1_1_c0 {
		width: 108rpx;
		height: 108rpx;
		border-radius: 54rpx;
		margin: 0rpx 23rpx 0rpx 0rpx;
	}

	.otherFollow_fd1_1 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.otherFollow_fd1_0_c1 {
		color: var(--benbenFontColor0);
	}

	.otherFollow_fd1_0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.otherFollow_fd1_0 {
		background: #F8F8F8;
		margin: 24rpx 0rpx 16rpx 0rpx;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		height: 64rpx;
		padding: 0rpx 32rpx 0rpx 32rpx;
	}
</style>